module hzrd_detect(opcode, Rs_val, T);
 input[4:0] opcode;  //inst[15:11]
 input[15:0] Rs_val;

 output T; //1 for taken, 0 for not taken

 assign T = (opcode[4:2] != 3'b011)?                    0 :    //not a branch instruction
             (opcode[1:0] == 2'b00)? {Rs_val == 16'h0000} :  //Rs_val==0, T=1
             (opcode[1:0] == 2'b01)? {Rs_val != 16'h0000} : //Rs_val~=0, T=1
             (opcode[1:0] == 2'b10)?         {Rs_val[15]} :   //Rs_val<0, T=1
                                            {!Rs_val[15]} ;  //rs_val>=0, T=1

endmodule

